package top.carrotguo.weibo.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.orhanobut.logger.Logger;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import top.carrotguo.weibo.R;

public class StringAdapter extends RecyclerView.Adapter {

    private ArrayList<String> datas;

    public StringAdapter(ArrayList<String> datas){
        this.datas = datas;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_text,viewGroup,false);
        return new TextViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
        TextViewHolder holder = (TextViewHolder) viewHolder;
        holder.tvText.setText(datas.get(i));
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class TextViewHolder extends RecyclerView.ViewHolder{

        @BindView(R.id.tv_text)
        TextView tvText;

        public TextViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

}
